FORTRAN Character String Utilities

A number of executable programs accept input from a user-provided ASCII text file. These input files specify which operations to perform and supply the necessary input data. The string routines supplied here were developed to simplify the processing of these input files. In particular, there are subroutines for parsing lines in the input file into their component parts (e.g., commands, arguments, parameters) based on prescribed delimiters. There are also subroutines for performing various string manipulations as well as routines for evaluating mathematical expressions contained in strings. The FORTRAN routines are contained in two modules. The module strings contains the parsing and basic manipulation routines. The module evaluate contains routines for evaluating mathematical expressions contained in strings.

FORTRAN Strings Module

This FORTRAN module contains routines for parsing input lines such as

cmd arg1, arg2, arg3

into the component strings "cmd", "arg1", "arg2", "arg3" based on prescribed delimiters such as commas and spaces. There are also routines for converting number strings into numerical values (integers, reals, single or double precision). Other routines in this module

  • convert strings to uppercase or lowercase
  • remove portions of strings
  • insert strings into other strings
  • find matching delimiters such as (), [], {}, <>
  • determine whether a character is a letter or a digit (0-9).

A document describing this string module can be opened by clicking on the link Strings.pdf.

The FORTRAN source code and associated documentation is in the file Strings.zip that can be obtained by clicking on the link Source Code for FORTRAN String Utilities

FORTRAN Evaluate Module

This module contains routines for evaluating mathematical expressions contained in strings, e.g.,
"cos((a+b)^2+1.6*log(c))".
These strings expressions can contain numbers (e.g., 1.5 or 1.5e6), previously defined parameters (like a,b,c above), arithmetic operators (+,-,*,/,^), and any of the functions (cos, sin, sqrt, exp, log, ln, abs, ang, real, imag, conjg, complex). They can also contain nested levels of parentheses. The module also contains routines for defining and retrieving user-specified parameters. The quantity pi and the imaginary unit i are pre-defined parameters. The document describing this Evaluate Module can be opened by clicking on the link evaluate.pdf.

The Evaluate Module and the associated documentation can be downloaded by clicking on the link evaluate.zip.

A Windows command-line calculator utilizing the Evaluate Module is contained in the downloadable file calc.zip.